package com.example.swaggerDemo.controller;

import com.example.swaggerDemo.entity.MsgEntity;
import com.example.swaggerDemo.entity.articeByUseridEntity;
import com.example.swaggerDemo.service.articeByUseridService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.sql.SQLException;
import java.util.List;

@Api("查看广告列表用户")
@RestController
@RequestMapping(value="/ArticleByuser")
public class articleUserController {
    @Autowired
    private articeByUseridService Service;

    @ApiOperation(value="查询",notes="查询所有文章信息")
    @ResponseBody
    @RequestMapping(value="/findAll",method= RequestMethod.POST)
    public Object findAll(@RequestParam("pageindex") int pageindex, @RequestParam("pagesize") int pagesize,@RequestParam("username") String username,@RequestParam("id") String id) {
        MsgEntity msg=new MsgEntity();
        try {
            List<articeByUseridEntity> dto = Service.findAll(pageindex,pagesize,id,username);
            if ( dto.size()>0){
                msg.msg="数据查询成功";
                msg.code=true;
                msg.object=dto;
            }
            else
            {
                msg.msg="没有查询导数据";
                msg.code=false;
                msg.object=dto;
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return msg;
    }

}
